﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>

<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdAgreementElements";
                                        settings.KeyFieldName = "IdAgreementElement";
                                        settings.CallbackRouteValues =
                                            new { Controller = "Customers", Action = "AgreementElementsEdit", customerId = Model.IdCustomer };
                                        settings.SettingsPager.PageSize = 20;



                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Customers", Action = "AgreementElementsUpdate", customerId = Model.IdCustomer };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Customers", Action = "AgreementElementsAdd", customerId = Model.IdCustomer };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Customers", Action = "AgreementElementsDelete", customerId = Model.IdCustomer };

                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = false;


                                        
                                        
                                        settings.ControlStyle.Paddings.Padding = Unit.Pixel(0);
                                        settings.ControlStyle.Border.BorderWidth = Unit.Pixel(0);
                                        settings.ControlStyle.BorderBottom.BorderWidth = Unit.Pixel(1);

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.LegalEntityName;
                                            column.FieldName = "IdLegalEntityExt";
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {

                                                comboBoxProperties.DataSource =
                                                    Model.LegalEntities;
                                                comboBoxProperties.TextField = "Name";
                                                comboBoxProperties.ValueField = "IdLegalEntity";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }

                                            

                                        });

                                        //settings.Columns.Add(column =>
                                        //                         {
                                        //                             column.Caption = Resourses.OwnershipPattern;
                                        //                             column.FieldName = "IdOwnershipPatternExt";
                                        //                             column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                        //                             var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                        //                             if (comboBoxProperties != null)
                                        //                             {
                                        //                                 var col = new OwnershipsPatternsCollection();
                                        //                                 comboBoxProperties.DataSource =
                                        //                                     col.OwnershipsPatternsList;
                                        //                                 comboBoxProperties.TextField = "LocalizedName";
                                        //                                 comboBoxProperties.ValueField = "IdOwnershipPattern";
                                        //                                 comboBoxProperties.ValueType = typeof(int);
                                        //                             }
                                        //                         });
                                        //settings.Columns.Add(column=>
                                        //                         {
                                        //                             column.FieldName = "IdOwnershipPatternExt";
                                        //                             column.Caption =
                                        //                                 Resourses.OwnershipPatternShortName;
                                        //                             column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                        //                             var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                        //                             if (comboBoxProperties != null)
                                        //                             {
                                        //                             var col=new 
                                        //                             ///    comboBoxProperties.DataSource = DB.GetLocalizedOwnershipPatternsShortNames();
                                        //                                 //collection.EquipmentTypes;
                                        //                                 comboBoxProperties.TextField = "LocaLizedString";
                                        //                                 comboBoxProperties.ValueField = "Id";
                                        //                                 comboBoxProperties.ValueType = typeof(int);
                                        //                             }
                                        //                         });
                                        //settings.Columns.Add(column =>
                                        //{
                                        //    column.FieldName = "FullNameExt";
                                        //    column.Caption = Resourses.LegalEntityFullName;
                                        //});
                                        settings.Columns.Add(column=>
                                                                 {
                                                                     column.FieldName = "FIOGenDirInRPExt";
                                                                     column.Caption = Resourses.FIOGenDirInRP;
                                                                 });
                                        settings.Columns.Add(column=>
                                                                 {
                                                                     column.FieldName = "FIOGenDirExt";
                                                                     column.Caption = Resourses.FIOGenDir;
                                                                 });

                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "FIOGenDirInRPShort";
                                            column.Caption = Resourses.FIOGenDirShortInRp;
                                        });
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "FIOGenDirShort";
                                            column.Caption = Resourses.FIOGenDirShort;
                                        });
                                        
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "PostIndexExt";
                                            column.Caption = Resourses.PostIndex;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "FullAddressExt";
                                            column.Caption = Resourses.FullAddress;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "INNExt";
                                            column.Caption = Resourses.INN;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "KPPExt";
                                            column.Caption = Resourses.KPP;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "RSExt";
                                            column.Caption = Resourses.RS;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "KSExt";
                                            column.Caption = Resourses.KS;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "BIKExt";
                                            column.Caption = Resourses.BIK;
                                        });
                                       
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "BankExt";
                                            column.Caption = Resourses.Bank;
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "OGRNExt";
                                            column.Caption = Resourses.OGRN;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "OKPO";
                                            column.Caption = Resourses.OKPO;
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IsActive";
                                            column.Caption = Resourses.IsActive;
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });
                                        

                                        //конец комбобокса
                                    })
       .Bind(Model.AgreementElements).GetHtml();%>